package com.sheep.spark.rest.service;

/**
 * Created by Administrator on 2016/1/20.
 */

import com.sheep.api.bean.ADSBBean;
import com.sheep.spark.rest.support.SparkSupport;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import java.util.List;

// @Path here defines class level path. Identifies the URI path that
// a resource class will serve requests for.
@Path("ADSB")
public class ADSBInfo {

    // @GET here defines, this method will method will process HTTP GET
    // requests.
    @GET
    // @Path here defines method level path. Identifies the URI path that a
    // resource class method will serve requests for.
    @Path("/name/{i}")
    // @Produces here defines the media type(s) that the methods
    // of a resource class can produce.
    @Produces(MediaType.TEXT_XML)
    // @PathParam injects the value of URI parameter that defined in @Path
    // expression, into the method.
    public String userName(@PathParam("i") String i) {

        String name = i;
        return "<User>" + "<Name>" + name + "</Name>" + "</User>";
    }

//    @GET
//    @Path("createSimpleBean/{a}/{b}/{c}")
//    @Produces( MediaType.APPLICATION_JSON)
//    public TestBean createSimpleBean(@PathParam(value="a")String a, @PathParam(value="b")int b, @PathParam(value="c")long c) {
//        return new TestBean(a, b, c);
//    }

    @GET
    @Path("/age/{j}")
    @Produces(MediaType.TEXT_XML)
    public String userAge(@PathParam("j") int j) {

        int age = j;
        return "<User>" + "<Age>" + age + "</Age>" + "</User>";
    }

    @GET
    @Path("/{year}/{month}/{date}")
    @Produces(MediaType.TEXT_XML)
    public String test(@PathParam("year") String year, @PathParam("month") String month, @PathParam("date") String date) {

        return "<User>" + "<Year>" + year + "</Year>" + "<Month>" + month + "</Month>" + "<Date>" + date + "</Date>" + "</User>";
    }

    @GET
    @Path("/{year}/{month}/{date}/{an}/{fi}/{compress}")
    @Produces(MediaType.TEXT_XML)
    public String getADSB(@PathParam("year") String year, @PathParam("month") String month, @PathParam("date") String date, @PathParam("an") String an, @PathParam("fi") String fi, @PathParam("compress") boolean compress) {
        return compress?SparkSupport.getADSBByCompress(year, month, date, an, fi):SparkSupport.getADSBList(year, month, date, an, fi);
    }

//    @GET
//    @Path("/compress/{year}/{month}/{date}/{an}/{fi}")
//    @Produces(MediaType.TEXT_XML)
//    public String getADSB(@PathParam("year") String year, @PathParam("month") String month, @PathParam("date") String date, @PathParam("an") String an, @PathParam("fi") String fi) {
//        return SparkSupport.getADSBByCompress(year, month, date, an, fi);
//    }
}
